package com.kaixin.connect;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.secneo.appshare.activities.LoginChooseMethodActivity;

public class KaixinJavaScriptInterface {

	NotifyKaixinVerify listener ;

	public KaixinJavaScriptInterface(NotifyKaixinVerify listener) {
		this.listener = listener ;
	}

	public void getHTML(String html) {
		String pin = getPin(html);
		
		if(pin.length() == 6){
			listener.SetKaixinVerify(pin) ;
		}
	}

	public String getPin(String html) {
		String ret = "";
		String regEx = "[0-9]{6}</li>";
		Pattern p = Pattern.compile(regEx);
		Matcher m = p.matcher(html);
		boolean result = m.find();
		if (result) {
			ret = m.group(0);
			ret = ret.substring(0 , 6) ;
		}
		
		return ret ;
	}
}
